<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="<c:url value='/css/Pub.css'/>"></link>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- 如果出现没有效果的情况直接检查是否是因为路径的问题 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css"
          type="text/css"></link>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/easyui/themes/icon.css" type="text/css"></link>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>

    <style type="text/css">
        a {
            text-decoration: none;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="<c:url value='/css/Pub.css'/>"></link>
    <script type="text/javascript">
        var path = "<c:url value='/'/>";
    </script>
    <style type="text/css">
        td {
            text-align: center
        }
    </style>
</head>
<body>
<p>订单列表：</p>
<table class="easyui-datagrid" style="width:800px;height:350px"
       data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
    <thead>
    <tr>
        <th data-options="field:'orderid',width:100">订单号</th>
        <th data-options="field:'orderconsignee',width:150">收货人明细</th>
        <th data-options="field:'orderamt',width:100">总金额</th>
        <th data-options="field:'orderstate',width:100">订单状态</th>
        <th data-options="field:'orderpaytype',width:100">付款方式</th>
        <th data-options="field:'orderdate',width:102">下单时间</th>
        <th data-options="field:'ordercancle',width:100">操作</th>
    </tr>
    </thead>

    <tbody>

    <c:forEach items="${orders}" var="order">
        <tr style="algin:center;">
            <td>
                <a href="${pageContext.request.contextPath }/order?action=queryOne&id=${order.id}">
                        ${order.id}
                </a>
            </td>
            <td>
                    ${order.consignee}
            </td>
            <td>
                    ${order.amt}元
            </td>
            <td>
                <c:choose>
                    <c:when test="${order.state==0}">
                        等待发货
                    </c:when>
                    <c:when test="${order.state==1}">
                        商家已发货
                    </c:when>
                    <c:when test="${order.state==2}">
                        交易已经完成
                    </c:when>
                    <c:when test="${order.state==3}">
                        交易已经取消
                    </c:when>
                    <c:when test="${order.state==4}">
                        客户已退货
                    </c:when>
                </c:choose>
            </td>
            <td>
                <c:choose>
                    <c:when test="${order.paytype==1}">
                        货到付款
                    </c:when>
                    <c:otherwise>
                        网银付款
                    </c:otherwise>
                </c:choose>
            </td>
            <td>
                    ${order.orderdate}
            </td>
            <td>
                <c:if test="${order.state==0}">
                    <button onclick="_cancle('${order.id}');">取消订单</button>
                </c:if>
            </td>
        </tr>
    </c:forEach>

    </tbody>

</table>

</body>

<script type="text/javascript">

    //取消订单
    function _cancle(id) {
        var url = "${pageContext.request.contextPath}/order?action=cancleOrder&id=" + id;
        window.location.href = url;
    }
</script>
</html>
